package com.hup.utils.commons.exception;

import java.util.ArrayList;
import java.util.List;

/**
 * @author hugan
 * @date 2019/12/13
 */
public class MultiException extends RuntimeException {

    private final List<Exception> exceptions;

    private MultiException(List<Exception> exceptions) {
        this.exceptions = exceptions;
    }

    @Override
    public String getMessage() {
        return "错误数量=" + exceptions.size();
    }

    public List<Exception> getExceptions() {
        return exceptions;
    }

    public static void doAssert(ArrayList<Exception> list) {
        if (!list.isEmpty()) {
            throw new MultiException(list);
        }
    }
}
